﻿namespace Tiscs.Practices.Security
{
	/// <summary>
	/// 权限描述类。
	/// </summary>
	public class Authority : AuthorityBase
	{
		/// <summary>
		/// 构造方法。
		/// </summary>
		/// <param name="allowUsers">授权访问的用户列表。</param>
		/// <param name="allowRoles">授权访问的角色列表。</param>
		/// <param name="denyUsers">拒绝访问的用户列表。</param>
		/// <param name="denyRoles">拒绝访问的角色列表。</param>
		public Authority(string[] allowUsers = null, string[] allowRoles = null, string[] denyUsers = null, string[] denyRoles = null)
		{
			AllowUsers = allowUsers;
			AllowRoles = allowRoles;
			DenyUsers = denyUsers;
			DenyRoles = denyRoles;
		}

		private string[] _allowUsers;

		/// <summary>
		/// 获取或设置授权访问的用户列表。
		/// </summary>
		public string[] AllowUsers
		{
			get { return _allowUsers;}
			set { _allowUsers = value;}
		}

		private string[] _allowRoles;

		/// <summary>
		/// 获取或设置授权访问的角色列表。
		/// </summary>
		public string[] AllowRoles
		{
			get { return _allowRoles;}
			set { _allowRoles = value;}
		}

		private string[] _denyUsers;

		/// <summary>
		/// 获取或设置拒绝访问的用户列表。
		/// </summary>
		public string[] DenyUsers
		{
			get { return _denyUsers;}
			set { _denyUsers = value;}
		}

		private string[] _denyRoles;

		/// <summary>
		/// 获取或设置拒绝访问的角色列表。
		/// </summary>
		public string[] DenyRoles
		{
			get { return _denyRoles;}
			set { _denyRoles = value;}
		}

		/// <summary>
		/// 获取授权访问的用户列表。
		/// </summary>
		/// <returns>授权访问的用户列表。</returns>
		protected override string[] GetAllowUserArray()
		{
			return AllowUsers;
		}

		/// <summary>
		/// 获取授权访问的角色列表。
		/// </summary>
		/// <returns>授权访问的角色列表。</returns>
		protected override string[] GetAllowRoleArray()
		{
			return AllowRoles;
		}

		/// <summary>
		/// 获取拒绝访问的用户列表。
		/// </summary>
		/// <returns>拒绝访问的用户列表。</returns>
		protected override string[] GetDenyUserArray()
		{
			return DenyUsers;
		}

		/// <summary>
		/// 获取拒绝访问的角色列表。
		/// </summary>
		/// <returns>拒绝访问的角色列表。</returns>
		protected override string[] GetDenyRoleArray()
		{
			return DenyRoles;
		}
	}
}
